<template>
    <div class="allCustomersManagement" id="allCustomersZ">
      <div class="newArticleStyle">
        <Select
          v-model="nameCrimeSceneVal"
          placeholder="请选择案场名称"
          filterable
          @on-select="nameCrimeSceneFun"
          style="width: 200px;">
          <Option v-for="(item, index) in nameCrimeSceneList" :value="item.buildingId" :key="index">{{ item.buildingAlias}}</Option>
        </Select>       
        <div class="imprt">
          <Button type="primary" @click="newCustomerFun" v-if="unlocking('客户管理', '3000001')">新建客户</Button>        
           <Poptip v-model="exportVisible" trigger="hover">
              <Button type="primary">导出Excel</Button>                  
              <div slot="content">
                  <div class="impotBtn" @click="exportExcelFun(2)">导出全部字段</div>
                  <div class="impotBtn" @click="exportExcelFun(1)">导出台账字段</div>
              </div>
          </Poptip>
          <Button type="primary" @click="assignCustomers" v-if="unlocking('客户管理', '5000031')">分配客户</Button>    
          <Button type="primary" @click="adjustHeader">调整表头排序</Button>    
          <Button type="primary" @click="goStandBookList">编辑本案台账</Button>    
          <Button type="primary" @click="importAccount" v-if="unlocking('客户管理', '5000034')">导入台账</Button>    
          
        </div>
      </div>
      <!-- <Table :loading="loading" ref="TableHeight" :max-height="onresizeHeight" :columns="columns" :data="data1" @on-row-click="viewClick"></Table> -->
      <Table :loading="loading" class="tab" ref="TableHeight" :max-height="onresizeHeight" :columns="columns" :data="data1"></Table>
      <!-- 分页 -->
      <div class="pagePublicStyle" v-show="pageData.total > 0">
        <div class="totalCount">
          当前第 {{pageData.page}} 页，
          当前第 {{(pageData.page-1)*pageData.rows+1}} 条到第 {{pageData.page*pageData.rows>pageData.total?pageData.total:pageData.page*pageData.rows}} 条，
          共 {{pageData.total}} 条
        </div>
        <Page class="pager" :total="pageData.total" :pageSize="pageData.rows" :current="pageData.page" :page-size-opts="pageData.pageSizeOpts" @on-change="pageOnChangeFun" @on-page-size-change="pageOnPageSizeChangeFun" placement="top" show-elevator show-sizer />
      </div>
      <!-- table 头部筛选 -->
      <table_filter :options="options" :channelType="true" :channelList="sourceChannelList"   @cancelFilterFun="cancelFilterFun" @okFilterFun="okFilterFun" @openChangeFun="openChangeFun"></table_filter>

      <!-- 穿梭框 -->
      <shuttle-box :transforFlag='transforFlag' @fieldCancel="fieldCancel" @headupdata="headupdata"  :sourcedata="sourcedata"  :targetdata="targetdata" ></shuttle-box>


      <Modal
        v-model="importFlag"
        title="台账导入"
        :footer-hide="true"
        width='800'
        @on-cancel="importAccountCancel">
        <Table
          :columns="importColumns"
          :data="importData"
          max-height="400"
        >
        </Table>

        <div class="transferFooter">
          <Button @click="importAccountCancel">取消</Button>
          <Upload 
            :disabled="importStatusFlag"
            :action="importParameterExcel"
            :format="['xlsx','xls','XLS','XLSX']"
            ref="upload"   
            :data="dataParams" 
            name="excelFile"
            :headers="uploadHeaders"
            :on-format-error="handleFormatError"
            :before-upload="handleBefore"
            :on-error="handleError"
            :on-progress="handleProgress"
            :show-upload-list="false"
          >
            <Tooltip placement="top" max-width="200"  content="当前已有正在执行的导入任务，请稍后再试" :disabled="!importStatusFlag">
              <Button type="primary" :disabled="importStatusFlag">导入台账</Button>
            </Tooltip>
          </Upload>
        </div>
    </Modal>

    </div>
</template>
<script>
  import { teams, getCustomerListNew,aggChannelQueryGroupBuilding,customerHeadList,followUp,updateFollowUp,importCustomerList,getUserByName,selectAggregationCriteria} from "@/api/customerManagement.js";
  import { cityBaseList } from "@/api/materialManagement.js";
  import table_filter from '@/components/table_filter'
  import shuttleBox from '@/components/shuttleBox'
  import configs from "@/common/config"
  import tool from "@/common/tool"
  import Helper from "@/common/helper.js";
  import {buildExport} from "@/common/axios"
  import  poptipContent  from "./components/poptipContent";
  export default {
    components: {
      table_filter,
      shuttleBox,
      poptipContent
    },
    data() {
        return {
          popLoading:true,
          importStatusFlag:false,
          importStatusFlag1:false,
          exportParams:{},
          exportVisible:false,
          popClass:"",
          dataParams:{
            userId:Number(JSON.parse(tool.getStorage('userMess')).userId)
          },
          popLen:0,
          importFlag:false,
          importData:[],
          importColumns: [
            {
              title: "文件名称",
              key: "formName",
              minWidth: 100,
            },
            {
              title: "导入状态",
              key: "status",
              minWidth: 100,
              
              render: (h, params) => {
                return h('div', {
                  style:{
                    color:params.row.status==0?"#ed4014":"#515a6e"
                  },
                },
                 this.$formatter.switchName('importStatus',params.row.status) );
              },

              
            },
            {
              title: "导入时间",
              key: "updateTime",
              minWidth: 160,
              render: (h, params) => {
                return h('div', params.row.updateTime&&params.row.updateTime!='-'?this.$tool.dateFtt('yyyy/MM/dd hh:mm',params.row.updateTime):'-');
              },
            },
            {
              title: "操作",
              key: "result",
              minWidth: 80,
              render: (h, params) => {
                  return h('div', [
                    h('span', {
                      props:{
                        type:'text'
                      },
                      style:{
                        color:'#2d8cf0',
                        cursor:"pointer"
                      },
                      on: {
                        click: (e) => {
                          e.stopPropagation();
                          this.importDownload(params.row.id);
                        }
                      }
                    }, params.row.status==1?'下载':''),
                  ]);
                }
            },
          ],
          

          
          //跟进记录
          followUpList:[], 
          
          // 穿梭框
          transforFlag:false,
          sourcedata:[],
          targetdata:[],



          statisticsFlag:false,//是否从首页统计来
          caseBuildingId:JSON.parse(this.$tool.getStorage("caseBuildingId")),
          // buildingAlias:JSON.parse(this.$tool.getStorage("caseBuildingId")),
          importParameterExcel:process.env.VUE_APP_API_URL?process.env.VUE_APP_API_URL+'/dt-business/parameter/importParameterExcel':configs.baseURL.target+'/dt-business/parameter/importParameterExcel',
          uploadHeaders: {
            'token':tool.getStorage("X-Token"),
            'appId':tool.getStorage("appId")            
          },


          appId: this.$tool.getStorage("appId"),
          nameCrimeSceneVal: '',
          nameCrimeSceneList: [],
          roleName: JSON.parse(tool.getStorage('userMess')).currentRole.roleName,
          loading: false,
          onresizeHeight: 0,
          pageData: {
            total: 0,
            page: 1,
            rows: 50,
            pageSizeOpts: [50, 40, 30, 20, 10]
            // pageSizeOpts: [10, 20, 30, 40, 50]
          },
          sourceChannelList:[],//渠道列表
          // statusList: ['-', '预约', '首访', '回笼', '验资', '认筹', '意向金', '认购', '签约', '付款', '交房;B+', '互动', '留资', '到访', '认购', '签约', '退购', '退签'],
          options: {
            type: '',   // form类型  Input / DatePicker / Checkbox / Select / 操作配置头部
            nameCrimeSceneName: '',
            nameCrimeSceneVal: '',
            placeholder: '',  // 提示语
            left: -1000,    // 弹框fixed => left
            iconLeft: 0,  // 弹框icon => left
            top: -1000,    // 弹框fixed => top
            width: 218,   // 弹框fixed => top
            setTimeout: null,    // 鼠标离开三角形 200毫秒 关闭弹框



            customerName: '',  // 客户姓名 字段
            phoneNumber: '', // 电话 字段



            sourceChannelVal: '',//来源渠道
            // sourceChannelList:[],

            customerProgressVal: '',//客户进度字段
            customerProgressList:[],//客户进度筛选数据
            
            customerLevelVal:'', // 客户等级 字段
            customerLevelList: [], //客户等级 数据

            intentionPurposeVal:'',//置业目的
            intentionPurposeList:[],

            intentionProductVal:'',//意向业态
            intentionProductList:[],

            intentionAreaVal:'',//意向面积
            intentionAreaList:[],

            intentionTotalPriceVal:'',//意向总价
            intentionTotalPriceList:[],

            intentionAveragePriceval:'',//意向单价
            intentionAveragePriceList:[],

            intentionHouseTypeVal:'',//意向户型
            intentionHouseTypeList:[],

            areaVal: '',  // 意向区域
            areaList: [],  

            sourceTypeVal:'',//创建方式
            sourceTypeList:[{name:'扫码授权',val:1},{name:'手动录入',val:2},{name:'网络来客',val:3}],

            checkInMethodVal:'',//签到方式
            checkInMethodList:[{name:'扫码签到',val:1},{name:'手动签到',val:2},{name:'新增签到',val:3},],

            createTimeVal:'',//创建时间

            lastVisitTimeVal:'',//最近到访时间

            lastFollowUpTimeVal:'',//最近跟进时间

            attributionConsultantVal:'',//归属顾问
            attributionConsultantList:[],
          },
          columns: [],
          columns2: {
            customer_name:{
              title: '客户姓名',
              key: 'customer_name',
              minWidth: 130,
              fixed: 'left',
              render: (h, params) => {
                return h('div',  params.row.customerName || '-');
              },
              renderHeader: (h, params) => {
                return h('div',[
                  h('span', {}, '客户姓名'),
                  h('Icon', {
                    props: {
                      type: 'ios-arrow-down',
                      size: '16'
                    },
                    style: {
                      marginLeft: '5px'
                    },
                    nativeOn: {
                      'mouseover': (event) => {
                        event.stopPropagation();
                        this.thMouseoverFun(event, 'input-customerName', '请输入客户姓名', 218);
                      },
                      'mouseleave': (event) => {
                        event.stopPropagation();
                        this.thMouseoutFun();
                      }
                    }
                  })
                ])
              }
            },
            customer_phone:{
              title: '手机号码',
              key: 'customer_phone',
              minWidth: 130,
              fixed: 'left',
              render: (h, params) => {
                return h('div',  this.$options.filters.mobilePhoneNumberFourAsterisk(params.row.customerPhone) || '-');
              },
              renderHeader: (h, params) => {
                return h('div',[
                  h('span', {}, '手机号码'),
                  h('Icon', {
                    props: {
                      type: 'ios-arrow-down',
                      size: '16'
                    },
                    style: {
                      marginLeft: '5px'
                    },
                    nativeOn: {
                      'mouseover': (event) => {
                        event.stopPropagation();
                        this.thMouseoverFun(event, 'input-phoneNumber-11', '请输入手机号码', 260);
                      },
                      'mouseleave': (event) => {
                        event.stopPropagation();
                        this.thMouseoutFun();
                      }
                    }
                  })
                ])
              }
            },


            attribution_consultant:{
              title: '归属顾问',
              key: 'attribution_consultant',
              minWidth: 150,
              fixed: 'left',
              render: (h, params) => {
                return h('div', params.row.attributionConsultant||'-');
              },
              renderHeader: (h, params) => {
                return h('div',[
                  h('span', {}, '归属顾问'),
                  h('Icon', {
                    props: {
                      type: 'ios-arrow-down',
                      size: '16'
                    },
                    style: {
                      marginLeft: '5px'
                    },
                    nativeOn: {
                      'mouseover': (event) => {
                        event.stopPropagation();
                        this.thMouseoverFun(event, 'Select-attributionConsultantVal-attributionConsultantList-multiple', '请选择归属顾问', 200);
                      },
                      'mouseleave': (event) => {
                        event.stopPropagation();
                        this.thMouseoutFun();
                      }
                    }
                  })
                ])
              }
            },

            status:{
              title: '客户进度',
              key: 'status',
              minWidth: 120,
              render: (h, params) => {
                return h('div', (params.row.status || '-'));
              },
              renderHeader: (h, params) => {
                return h('div',[
                  h('span', {}, '客户进度'),
                  h('Icon', {
                    props: {
                      type: 'ios-arrow-down',
                      size: '16'
                    },
                    style: {
                      marginLeft: '5px'
                    },
                    nativeOn: {
                      'mouseover': (event) => {
                        event.stopPropagation();
                        this.thMouseoverFun(event, 'Select-customerProgressVal-customerProgressList-multiple', '请选择客户进度', 200);
                      },
                      'mouseleave': (event) => {
                        event.stopPropagation();
                        this.thMouseoutFun();
                      }
                    }
                  })
                ])
              }
            },

            channel_source:{
              title: '来源渠道',
              key: 'channel_source',
              minWidth: 120,
              render: (h, params) => {
                return h('div', params.row.channelSource || '-');
              },
              renderHeader: (h, params) => {
                return h('div',[
                  h('span', {}, '来源渠道'),
                  h('Icon', {
                    props: {
                      type: 'ios-arrow-down',
                      size: '16'
                    },
                    style: {
                      marginLeft: '5px'
                    },
                    nativeOn: {
                      'mouseover': (event) => {
                        event.stopPropagation();
                        this.thMouseoverFun(event, 'SelectChannel-sourceChannelVal-aa-multiple', '请选择来源渠道', 200);
                      },
                      'mouseleave': (event) => {
                        event.stopPropagation();
                        this.thMouseoutFun();
                      }
                    }
                  })
                ])
              }
            },
            intention_level:{
              title: '意向等级',
              key: 'intention_level',
              minWidth: 120,
              render: (h, params) => {
                return h('div',  params.row.intentionLevel || '-' );
              },
              renderHeader: (h, params) => {
                return h('div',[
                  h('span', {}, '意向等级'),
                  h('Icon', {
                    props: {
                      type: 'ios-arrow-down',
                      size: '16'
                    },
                    style: {
                      marginLeft: '5px'
                    },
                    nativeOn: {
                      'mouseover': (event) => {
                        event.stopPropagation();
                        this.thMouseoverFun(event, 'Select-customerLevelVal-customerLevelList-multiple', '请选择意向等级', 200);
                      },
                      'mouseleave': (event) => {
                        event.stopPropagation();
                        this.thMouseoutFun();
                      }
                    }
                  })
                ])
              }
            },
            intention_purpose:{
              title: '置业目的',
              key: 'intention_purpose',
              minWidth: 160,
              render: (h, params) => {
                return h("div", [
                  h(
                    "span",
                    {
                      style: {
                        display: "inline-block",
                        width: "100%",
                        overflow: "hidden",
                        textOverflow: "ellipsis",
                        whiteSpace: "nowrap"
                      },
                      domProps: {
                        title: params.row.intentionPurpose
                      }
                    },
                    params.row.intentionPurpose || '-'
                  )
                ]);
              },
              renderHeader: (h, params) => {
                return h('div',[
                  h('span', {}, '置业目的'),
                  h('Icon', {
                    props: {
                      type: 'ios-arrow-down',
                      size: '16'
                    },
                    style: {
                      marginLeft: '5px'
                    },
                    nativeOn: {
                      'mouseover': (event) => {
                        event.stopPropagation();
                        this.thMouseoverFun(event, 'Select-intentionPurposeVal-intentionPurposeList-multiple', '请选择置业目的', 200);
                      },
                      'mouseleave': (event) => {
                        event.stopPropagation();
                        this.thMouseoutFun();
                      }
                    }
                  })
                ])
              }
            },
            intention_product:{
              title: '意向业态',
              key: 'intention_product',
              minWidth: 120,
              render: (h, params) => {
                return h('div', params.row.intentionProduct || '-');
              },
              renderHeader: (h, params) => {
                return h('div',[
                  h('span', {}, '意向业态'),
                  h('Icon', {
                    props: {
                      type: 'ios-arrow-down',
                      size: '16'
                    },
                    style: {
                      marginLeft: '5px'
                    },
                    nativeOn: {
                      'mouseover': (event) => {
                        event.stopPropagation();
                        this.thMouseoverFun(event, 'Select-intentionProductVal-intentionProductList-multiple', '请选择意向业态', 200);
                      },
                      'mouseleave': (event) => {
                        event.stopPropagation();
                        this.thMouseoutFun();
                      }
                    }
                  })
                ])
              }
            },

            intention_house_type:{
              title: '意向户型',
              key: 'intention_house_type',
              minWidth: 160,
              render: (h, params) => {
                return h("div", [
                  h(
                    "span",
                    {
                      style: {
                        display: "inline-block",
                        width: "100%",
                        overflow: "hidden",
                        textOverflow: "ellipsis",
                        whiteSpace: "nowrap"
                      },
                      domProps: {
                        title: params.row.intentionHouseType
                      }
                    },
                    params.row.intentionHouseType
                  )
                ]);
              },
              renderHeader: (h, params) => {
                return h('div',[
                  h('span', {}, '意向户型'),
                  h('Icon', {
                    props: {
                      type: 'ios-arrow-down',
                      size: '16'
                    },
                    style: {
                      marginLeft: '5px'
                    },
                    nativeOn: {
                      'mouseover': (event) => {
                        event.stopPropagation();
                        this.thMouseoverFun(event, 'Select-intentionHouseTypeVal-intentionHouseTypeList-multiple', '请选择意向面积', 200);
                      },
                      'mouseleave': (event) => {
                        event.stopPropagation();
                        this.thMouseoutFun();
                      }
                    }
                  })
                ])
              }
            },
            intention_area:{
              title: '意向面积',
              key: 'intention_area',
              minWidth: 160,
              render: (h, params) => {
                return h("div", [
                  h(
                    "span",
                    {
                      style: {
                        display: "inline-block",
                        width: "100%",
                        overflow: "hidden",
                        textOverflow: "ellipsis",
                        whiteSpace: "nowrap"
                      },
                      domProps: {
                        title: params.row.intentionArea
                      }
                    },
                    params.row.intentionArea
                  )
                ]);
              },
              renderHeader: (h, params) => {
                return h('div',[
                  h('span', {}, '意向面积'),
                  h('Icon', {
                    props: {
                      type: 'ios-arrow-down',
                      size: '16'
                    },
                    style: {
                      marginLeft: '5px'
                    },
                    nativeOn: {
                      'mouseover': (event) => {
                        event.stopPropagation();
                        this.thMouseoverFun(event, 'Select-intentionAreaVal-intentionAreaList-multiple', '请选择意向面积', 200);
                      },
                      'mouseleave': (event) => {
                        event.stopPropagation();
                        this.thMouseoutFun();
                      }
                    }
                  })
                ])
              }
            },
            intention_total_price:{
              title: '意向总价',
              key: 'intention_total_price',
              minWidth: 160,
              render: (h, params) => {
                return h("div", [
                  h(
                    "span",
                    {
                      style: {
                        display: "inline-block",
                        width: "100%",
                        overflow: "hidden",
                        textOverflow: "ellipsis",
                        whiteSpace: "nowrap"
                      },
                      domProps: {
                        title: params.row.intentionTotalPrice
                      }
                    },
                    params.row.intentionTotalPrice
                  )
                ]);
              },
              renderHeader: (h, params) => {
                return h('div',[
                  h('span', {}, '意向总价'),
                  h('Icon', {
                    props: {
                      type: 'ios-arrow-down',
                      size: '16'
                    },
                    style: {
                      marginLeft: '5px'
                    },
                    nativeOn: {
                      'mouseover': (event) => {
                        event.stopPropagation();
                        this.thMouseoverFun(event, 'Select-intentionTotalPriceVal-intentionTotalPriceList-multiple', '请选择意向总价', 200);
                      },
                      'mouseleave': (event) => {
                        event.stopPropagation();
                        this.thMouseoutFun();
                      }
                    }
                  })
                ])
              }
            },
            intention_average_price:{
              title: '意向单价',
              key: 'intention_average_price',
              minWidth: 160,
              render: (h, params) => {
                return h("div", [
                  h(
                    "span",
                    {
                      style: {
                        display: "inline-block",
                        width: "100%",
                        overflow: "hidden",
                        textOverflow: "ellipsis",
                        whiteSpace: "nowrap"
                      },
                      domProps: {
                        title: params.row.intentionAveragePrice
                      }
                    },
                    params.row.intentionAveragePrice
                  )
                ]);
              },
              renderHeader: (h, params) => {
                return h('div',[
                  h('span', {}, '意向单价'),
                  h('Icon', {
                    props: {
                      type: 'ios-arrow-down',
                      size: '16'
                    },
                    style: {
                      marginLeft: '5px'
                    },
                    nativeOn: {
                      'mouseover': (event) => {
                        event.stopPropagation();
                        this.thMouseoverFun(event, 'Select-intentionAveragePriceVal-intentionAveragePriceList-multiple', '请选择意向单价', 200);
                      },
                      'mouseleave': (event) => {
                        event.stopPropagation();
                        this.thMouseoutFun();
                      }
                    }
                  })
                ])
              }
            },

            intention_region:{
              title: '意向区域',
              key: 'intention_region',
              minWidth: 140,
              render: (h, params) => {
                return h("div", [
                  h(
                    "span",
                    {
                      style: {
                        display: "inline-block",
                        width: "100%",
                        overflow: "hidden",
                        textOverflow: "ellipsis",
                        whiteSpace: "nowrap"
                      },
                      domProps: {
                        title: params.row.intentionRegion
                      }
                    },
                    params.row.intentionRegion || '-'
                  )
                ]);
              },
              renderHeader: (h, params) => {
                return h('div',[
                  h('span', {}, '意向区域'),
                  h('Icon', {
                    props: {
                      type: 'ios-arrow-down',
                      size: '16'
                    },
                    style: {
                      marginLeft: '5px'
                    },
                    nativeOn: {
                      'mouseover': (event) => {
                        event.stopPropagation();
                        this.thMouseoverFun(event, 'SelectCity-areaVal-areaList-multiple', '请选择意向区域', 200);
                      },
                      'mouseleave': (event) => {
                        event.stopPropagation();
                        this.thMouseoutFun();
                      }
                    }
                  })
                ])
              }
            },
            //写死两个
            source_type:{
              title: '创建方式',
              key: 'source_type',
              minWidth: 120,
              render: (h, params) => {
                return h('div', params.row.sourceType||'-');
              },
              renderHeader: (h, params) => {
                return h('div',[
                  h('span', {}, '创建方式'),
                  h('Icon', {
                    props: {
                      type: 'ios-arrow-down',
                      size: '16'
                    },
                    style: {
                      marginLeft: '5px'
                    },
                    nativeOn: {
                      'mouseover': (event) => {
                        event.stopPropagation();
                        this.thMouseoverFun(event, 'Select-sourceTypeVal-sourceTypeList-multiple', '请选择创建方式', 200);
                      },
                      'mouseleave': (event) => {
                        event.stopPropagation();
                        this.thMouseoutFun();
                      }
                    }
                  })
                ])
              }
            },
            check_in_method:{
              title: '签到方式',
              key: 'check_in_method',
              minWidth: 120,
              render: (h, params) => {
                return h('div', params.row.checkInMethod||'-');
              },
              renderHeader: (h, params) => {
                return h('div',[
                  h('span', {}, '签到方式'),
                  h('Icon', {
                    props: {
                      type: 'ios-arrow-down',
                      size: '16'
                    },
                    style: {
                      marginLeft: '5px'
                    },
                    nativeOn: {
                      'mouseover': (event) => {
                        event.stopPropagation();
                        this.thMouseoverFun(event, 'Select-checkInMethodVal-checkInMethodList-multiple', '请选择签到方式', 200);
                      },
                      'mouseleave': (event) => {
                        event.stopPropagation();
                        this.thMouseoutFun();
                      }
                    }
                  })
                ])
              }
            },


            // 三个时间
            create_time:{
              title: '创建日期',
              key: 'create_time',
              minWidth: 160,
              render: (h, params) => {
                return h('div',params.row.createTime&&params.row.createTime!='-'?this.$tool.dateFtt('yyyy/MM/dd hh:mm',params.row.createTime):'-');
              },
              renderHeader: (h, params) => {
                return h('div',[
                  h('span', {}, '创建日期'),
                  h('Icon', {
                    props: {
                      type: 'ios-arrow-down',
                      size: '16'
                    },
                    style: {
                      marginLeft: '5px'
                    },
                    nativeOn: {
                      'mouseover': (event) => {
                        event.stopPropagation();
                        this.thMouseoverFun(event, "datePicker-createTimeVal-daterange", '请选择创建日期', 200);
                        
                      },
                      'mouseleave': (event) => {
                        event.stopPropagation();
                        this.thMouseoutFun();
                      }
                    }
                  })
                ])
              }
            },
            last_visit_time:{
              title: '最近到访时间',
              key: 'last_visit_time',
              minWidth: 160,
              render: (h, params) => {
                return h('div', params.row.lastVisitTime&&params.row.lastVisitTime!='-'? this.$tool.dateFtt('yyyy/MM/dd hh:mm',params.row.lastVisitTime) :'-');
              },
              renderHeader: (h, params) => {
                return h('div',[
                  h('span', {}, '最近到访时间'),
                  h('Icon', {
                    props: {
                      type: 'ios-arrow-down',
                      size: '16'
                    },
                    style: {
                      marginLeft: '5px'
                    },
                    nativeOn: {
                      'mouseover': (event) => {
                        event.stopPropagation();
                        this.thMouseoverFun(event, "datePicker-lastVisitTimeVal-daterange", '请选择最近到访时间', 200);
                        
                      },
                      'mouseleave': (event) => {
                        event.stopPropagation();
                        this.thMouseoutFun();
                      }
                    }
                  })
                ])
              }
            },
            last_follow_up_time:{
              title: '最近跟进时间',
              key: 'last_follow_up_time',
              minWidth: 160,
              render: (h, params) => {
                return h('div', params.row.lastFollowUpTime&&params.row.lastFollowUpTime!='-'? this.$tool.dateFtt('yyyy/MM/dd hh:mm',params.row.lastFollowUpTime):'-');
              },
              renderHeader: (h, params) => {
                return h('div',[
                  h('span', {}, '最近跟进时间'),
                  h('Icon', {
                    props: {
                      type: 'ios-arrow-down',
                      size: '16'
                    },
                    style: {
                      marginLeft: '5px'
                    },
                    nativeOn: {
                      'mouseover': (event) => {
                        event.stopPropagation();
                        this.thMouseoverFun(event, "datePicker-lastFollowUpTimeVal-daterange", '请选择最近跟进时间', 200);
                        
                      },
                      'mouseleave': (event) => {
                        event.stopPropagation();
                        this.thMouseoutFun();
                      }
                    }
                  })
                ])
              }
            },




            gender:{
              title: '性别',
              key: 'gender',
              minWidth: 80,
              render: (h, params) => {
                return h('div',  params.row.gender || '-');
              }
            },
            
            standby_phone:{
              title: '备用号码',
              key: 'standby_phone',
              minWidth: 160,
              render: (h, params) => {
                return h("div", [
                  h(
                    "span",
                    {
                      style: {
                        display: "inline-block",
                        width: "100%",
                        overflow: "hidden",
                        textOverflow: "ellipsis",
                        whiteSpace: "nowrap"
                      },
                      domProps: {
                        title: params.row.standbyPhone
                      }
                    },
                    params.row.standbyPhone
                  )
                ]);
              }
            },
            wechat:{
              title: '微信号',
              key: 'wechat',
              minWidth: 160,
              render: (h, params) => {
                return h("div", [
                  h(
                    "span",
                    {
                      style: {
                        display: "inline-block",
                        width: "100%",
                        overflow: "hidden",
                        textOverflow: "ellipsis",
                        whiteSpace: "nowrap"
                      },
                      domProps: {
                        title: params.row.wechat
                      }
                    },
                    params.row.wechat
                  )
                ]);
              }
            },
            
            
            tel_change_visit:{
              title: '是否电转访',
              key: 'tel_change_visit',
              minWidth: 110,
              render: (h, params) => {
                return h('div', params.row.telChangeVisit || '-');
              }
            },
            
            intention_subway:{
              title: '意向地铁',
              key: 'intention_subway',
              minWidth: 160,
              render: (h, params) => {
                return h("div", [
                  h(
                    "span",
                    {
                      style: {
                        display: "inline-block",
                        width: "100%",
                        overflow: "hidden",
                        textOverflow: "ellipsis",
                        whiteSpace: "nowrap"
                      },
                      domProps: {
                        title: params.row.intentionSubway
                      }
                    },
                    params.row.intentionSubway
                  )
                ]);
              }
            },
            intention_loop_line:{
              title: '意向环线',
              key: 'intention_loop_line',
              minWidth: 140,
              render: (h, params) => {
                return h("div", [
                  h(
                    "span",
                    {
                      style: {
                        display: "inline-block",
                        width: "100%",
                        overflow: "hidden",
                        textOverflow: "ellipsis",
                        whiteSpace: "nowrap"
                      },
                      domProps: {
                        title: params.row.intentionLoopLine
                      }
                    },
                    params.row.intentionLoopLine
                  )
                ]);
              }
            },
            down_payment_interval:{
              title: '首付区间',
              key: 'down_payment_interval',
              minWidth: 120,
              render: (h, params) => {
                return h('div',  params.row.downPaymentInterval || '-');
              },
            },
            payment_ratio:{
              title: '付款比例',
              key: 'payment_ratio',
              minWidth: 110,
              render: (h, params) => {
                return h('div',  params.row.paymentRatio ? params.row.paymentRatio : '-');
              },
            },
            attention_building:{
              title: '关注楼栋',
              key: 'attention_building',
              minWidth: 110,
              render: (h, params) => {
                return h('div',  params.row.attentionBuilding || '-');
              },
            },
            attention_floor:{
              title: '关注楼层',
              key: 'attention_floor',
              minWidth: 120,
              render: (h, params) => {
                return h('div',  params.row.attentionFloor || '-');
              },
            },
            attention_factor:{
              title: '关注因素',
              key: 'attention_factor',
              minWidth: 160,
              render: (h, params) => {
                return h("div", [
                  h(
                    "span",
                    {
                      style: {
                        display: "inline-block",
                        width: "100%",
                        overflow: "hidden",
                        textOverflow: "ellipsis",
                        whiteSpace: "nowrap"
                      },
                      domProps: {
                        title: params.row.attentionFactor
                      }
                    },
                    params.row.attentionFactor || '-'
                  )
                ]);
              }
            },
            resistance_points:{
              title: '抗性因素',
              key: 'resistance_points',
              minWidth: 120,
              render: (h, params) => {
                return h("div", [
                  h(
                    "span",
                    {
                      style: {
                        display: "inline-block",
                        width: "100%",
                        overflow: "hidden",
                        textOverflow: "ellipsis",
                        whiteSpace: "nowrap"
                      },
                      domProps: {
                        title: params.row.resistancePoints
                      }
                    },
                    params.row.resistancePoints || '-'
                  )
                ]);
              }
            },
            number_visiting:{
              title: '来访人数',
              key: 'number_visiting',
              minWidth: 120,
              render: (h, params) => {
                return h('div',  params.row.numberVisiting || '-');
              }
            },
            visitor_structure:{
              title: '来访人员结构',
              key: 'visitor_structure',
              minWidth: 120,
              render: (h, params) => {
                return h('div',  params.row.visitorStructure || '-');
              }
            },
            his_first_time:{
              title: '首访时间',
              key: 'his_first_time',
              minWidth: 160,
              render: (h, params) => {
                return h('div',params.row.hisFirstTime&&params.row.hisFirstTime!='-'?this.$tool.dateFtt('yyyy/MM/dd hh:mm',params.row.hisFirstTime):'-');
              }
            },
            reception_time:{
              title: '接待时长',
              key: 'reception_time',
              minWidth: 120,
              render: (h, params) => {
                return h('div',  params.row.receptionTime || '-');
              }
            },
            age_range:{
              title: '客户年龄',
              key: 'age_range',
              minWidth: 120,
              render: (h, params) => {
                return h('div',  params.row.ageRange || '-');
              }
            },
            purchase_integral:{
              title: '购房积分',
              key: 'purchase_integral',
              minWidth: 120,
              render: (h, params) => {
                return h('div',  params.row.purchaseIntegral || '-');
              }
            },
            payment_type:{
              title: '付款方式',
              key: 'payment_type',
              minWidth: 120,
              render: (h, params) => {
                return h('div',  this.$formatter.switchName("paymentType", params.row.paymentType )  || '-');
              }
            },
            history_marriage:{
              title: '近期婚史',
              key: 'history_marriage',
              minWidth: 120,
              render: (h, params) => {
                return h('div',  params.row.historyMarriage || '-');
              }
            },
            census:{
              title: '户籍',
              key: 'census',
              minWidth: 120,
              render: (h, params) => {
                return h('div',  params.row.census || '-');
              }
            },
            buy_house_qualification:{
              title: '购房资质',
              key: 'buy_house_qualification',
              minWidth: 120,
              render: (h, params) => {
                return h('div',  params.row.buyHouseQualification || '-');
              }
            },
            loans_qualification:{
              title: '贷款资质',
              key: 'loans_qualification',
              minWidth: 120,
              render: (h, params) => {
                return h('div',  params.row.loansQualification || '-');
              }
            },
            family_structure:{
              title: '家庭结构',
              key: 'family_structure',
              minWidth: 120,
              render: (h, params) => {
                return h('div',  params.row.familyStructure || '-');
              }
            },
            living_area:{
              title: '居住区域',
              key: 'living_area',
              minWidth: 120,
              render: (h, params) => {
                return h("div", [
                  h(
                    "span",
                    {
                      style: {
                        display: "inline-block",
                        width: "100%",
                        overflow: "hidden",
                        textOverflow: "ellipsis",
                        whiteSpace: "nowrap"
                      },
                      domProps: {
                        title: params.row.livingArea
                      }
                    },
                    params.row.livingArea || '-'
                  )
                ]);
              }
            },
            working_area:{
              title: '工作区域',
              key: 'working_area',
              minWidth: 120,
              render: (h, params) => {
                return h("div", [
                  h(
                    "span",
                    {
                      style: {
                        display: "inline-block",
                        width: "100%",
                        overflow: "hidden",
                        textOverflow: "ellipsis",
                        whiteSpace: "nowrap"
                      },
                      domProps: {
                        title: params.row.workingArea
                      }
                    },
                    params.row.workingArea || '-'
                  )
                ]);
              }
            },
            vehicle:{
              title: '交通工具',
              key: 'vehicle',
              minWidth: 120,
              render: (h, params) => {
                return h('div',  params.row.vehicle || '-');
              }
            },
            industry:{
              title: '从事行业',
              key: 'industry',
              minWidth: 120,
              render: (h, params) => {
                return h("div", [
                  h(
                    "span",
                    {
                      style: {
                        display: "inline-block",
                        width: "100%",
                        overflow: "hidden",
                        textOverflow: "ellipsis",
                        whiteSpace: "nowrap"
                      },
                      domProps: {
                        title: params.row.industry
                      }
                    },
                    params.row.industry || '-'
                  )
                ]);
              }
            },
            position:{
              title: '职务职位',
              key: 'position',
              minWidth: 120,
              render: (h, params) => {
                return h('div',  params.row.position || '-');
              }
            },
            education_background:{
              title: '学历',
              key: 'education_background',
              minWidth: 120,
              render: (h, params) => {
                return h('div',  params.row.educationBackground || '-');
              }
            },
            capital_source:{
              title: '资金来源',
              key: 'capital_source',
              minWidth: 120,
              render: (h, params) => {
                return h('div',  params.row.capitalSource || '-');
              }
            },
            key_decision_maker:{
              title: '决策关键人',
              key: 'key_decision_maker',
              minWidth: 120,
              render: (h, params) => {
                return h('div',  params.row.keyDecisionMaker || '-');
              }
            },
            house_num:{
              title: '现有房产套数',
              key: 'house_num',
              minWidth: 140,
              render: (h, params) => {
                return h('div',  params.row.houseNum || '-');
              }
            },
            customer_feature:{
              title: '客户特征',
              key: 'customer_feature',
              minWidth: 200,
              render(h,params){

                return h("div",{
              
                  props:{
                    // disabled:params.row.buildingId?false:true,
                    type:'text'
                  },
                  style:{
                    cursor:"pointer"
                  }
                }, [
                  params.row.customerFeature?h('Poptip',
                  {
                    props: {
                      placement: 'right',
                      transfer:true,
                      width:"380",
                      trigger: "hover",
                       popperClass:'N_poptip'
                    },  
                  },
                  [
                    h('span',{class:'featureZ'},params.row.customerFeature),
                  
                    h('div',{
                      slot: 'content'
                    },params.row.customerFeature)
                    
                  ]):h('span',params.row.customerFeature)
                ])
              }
            },
            
            // {
            //   title: '置业计划发送',
            //   key: 'plan_is_send',
            //   minWidth: 120,
            //   render: (h, params) => {
            //     return h('div',  params.row.planIsSend || '-');
            //   }
            // },

            work_unit:{
              title: '工作单位',
              key: 'work_unit',
              minWidth: 110,
              render: (h, params) => {
                return h('div', params.row.workUnit || '-');
              }
            },
            annual_income:{
              title: '年收入',
              key: 'annual_income',
              minWidth: 110,
              render: (h, params) => {
                return h('div', params.row.annualIncome || '-');
              }
            },
            now_live_house:{
              title: '居住小区',
              key: 'now_live_house',
              minWidth: 110,
              render: (h, params) => {
                return h('div', params.row.nowLiveHouse || '-');
              }
            },
            home_count:{
              title: '置业次数',
              key: 'home_count',
              minWidth: 110,
              render: (h, params) => {
                return h('div', params.row.homeCount&&params.row.homeCount!='-'?params.row.homeCount:'-');
              }
            },
            visit_count:{
              title: '来访次数',
              key: 'visit_count',
              minWidth: 110,
              render: (h, params) => {
                return h('div', params.row.visitCount||'-');
              }
            },

            demand_land:{
              title: '需求地段',
              key: 'demand_land',
              minWidth: 110,
              render: (h, params) => {
                return h('div', params.row.demandLand||'-');
              }
            },
            cognitive_channel:{
              title: '认知途径',
              key: 'cognitive_channel',
              minWidth: 110,
              render: (h, params) => {
                return h('div', params.row.cognitiveChannel||'-');
              }
            },
          },
          data1: [],
          pageData1: {
            total: 0,
            page: 1,
            rows: 10,
            pageSizeOpts: [50, 40, 30, 20, 10]
          },
        }
    },
    methods: {

      
      // 更新跟进记录
      getUpdateFollowUp(val){       
        let params = {
          userCustomerId: val.userCustomerId,
          customerId: val.customerId,
          operatorId:JSON.parse(tool.getStorage('userMess')).userId,
          buildingId:this.nameCrimeSceneVal,
          category: '4',
        };

        updateFollowUp(params)
          .then((res) => {
            if(String(res) == "true"){
              val.newNews=2
            }          

          })
          .catch((err) => {
            this.$Message.error(err);
          });
      },

      //查询跟进记录
      getFollowUp(val){
        this.popLoading = true;
        this.popClass = "";
        console.log(val,'跟进人的信息');
        this.followUpList = [];
        this.popLen = 0;
        
        let params = {
          page:this.pageData1.page,
          rows:this.pageData1.rows,
          userCustomerId: val.userCustomerId,
          category: '4,12',
          buildingId:this.nameCrimeSceneVal,
          customerId:val.customerId,
          operatorId:JSON.parse(tool.getStorage('userMess')).userId
        };

        followUp(params)
          .then((res) => {
            console.log(res,'客户跟进记录');
            this.followUpList = res.records;
            this.popLen =  res.total;

            this.getUpdateFollowUp(val);
            this.popLoading = false;
            



          })
          .catch((err) => {
            this.$Message.error(err);
          });
      },
      // 导入格式判断
      handleFormatError (file) {
        this.$Message.error('只支持上传Excel表格！');
      },
      // 导入中
      handleProgress(){
        this.importFlag = false;
        this.$Message.info('导入中。');
        // this.importAccount()
      },
      // 导入前
      handleBefore(){        
        let statusFlag = this.importData.some(item=>{
          return item.status == 0
        })
        if(statusFlag){
          this.$Message.info('当前已有正在执行的导入任务，请稍后再试。');
          return false;
        }else{
          return true;
        }
        
      },
      importAccountCancel(){
        this.importFlag = false;
      },
      importAccount(){
        this.importFlag = true;
        let params = {
          userId: JSON.parse(tool.getStorage("userMess")).userId,
        };
        importCustomerList(params)
          .then((res) => {
            this.importData = res;


            let statusFlag = this.importData.some(item=>{
              return item.status == 0
            })
           
            if(statusFlag){
              // this.$Message.info('当前已有正在执行的导入任务，请稍后再试。');
              this.importStatusFlag =  true;
              this.importStatusFlag1= false
            }else{
              this.importStatusFlag =  false;
              this.importStatusFlag1= true
            }

             console.log(statusFlag,this.importStatusFlag,'statusFlag');


          })
          .catch((err) => {
            this.$Message.error(err);
          });
      },  



      goStandBookList(){
        this.$router.push({
          path:'/configure_center/standBook/standBookList',
          query: {
            fromCustomer:true,
          },
        });   
        
      },
      adjustHeader(){
        this.transforFlag = true;
      },
      fieldCancel(){
        this.transforFlag = false;
      },
      headupdata(){
        this.transforFlag = false;
        this.getCustomerHeadList()
      },
      //DT1.4获取表头
      getCustomerHeadList(){
        this.columns = []
        let params = {    
            appId:Number(JSON.parse(tool.getStorage('userMess')).appId) ,
            buildingId:Number(this.nameCrimeSceneVal)           
        };
        customerHeadList(params)
          .then((res) => {
            console.log("DT1.4表头", res);
            this.sourcedata = res.hiedHead;
            this.targetdata = res.showHead;           
         
            console.log(Object.keys(this.columns2).length,'this.columns2.length');
            let temporary = [
              {
                title: '操作',
                key: 'address',
                fixed: 'right',
                width: 120,
                align: 'center',
                className: 'conciseContent',
                render: (h, params) => {
                  return h('div', [
                    h('Button', {
                      props:{
                        type:'text'
                      },
                      on: {
                        click: (e) => {
                          e.stopPropagation();
                          this.viewClick(params.row);
                        }
                      }
                    }, '查看详情'),

                    h(
                      "Poptip",
                      {
                        props: {
                          transfer:true,
                          width:"380",
                          trigger: "click",
                          confirm:true,
                          okText: this.popLen==0?"":`查看全部${this.popLen}条记录`,
                          cancelText:'关闭',
                          popperClass:'M_poptip'+' '+this.popClass,
                        },
                        style:{
                          // display:this.popFlag
                        },
                        
                        on: {
                            'on-ok': () => {
                              this.$router.push({
                                path: "/customerManagement_center/allCustomers/details",
                                query: {
                                  customerId: params.row.customerId,
                                  userCustomerId: params.row.userCustomerId,
                                  buildingId:JSON.parse(this.$tool.getStorage("caseBuildingId")),
                                  id: params.row.customerId,
                                  cityCode:this.nameCrimeSceneList.find(item=>item.buildingId == this.nameCrimeSceneVal).cityCode,
                                  isFollow:true
                                },
                              });
                            }
                          }
                        
                      },
                      [
                        h('Button', {
                          props:{
                            type:'text'
                          },
                          style: {
                              color:params.row.newNews=='1'?"#ed4014":"#0F42A7"
                          },
                          on: {
                            click: (e) => {
                              // e.stopPropagation();
                              this.getFollowUp(params.row);
                            },
                            
                          }
                        },  params.row.newNews=='1'?'有新的跟进': Number(params.row.followCount)? `跟进&批注(${params.row.followCount})`:'跟进&批注'),
                        h(poptipContent, {
                          slot: 'title',
                          props: {
                            followUpList:this.followUpList,
                            popData:params.row,
                            popLoading:this.popLoading
                          },
                          
                          on:{
                            popClose:(val)=>{
                              this.popClass = "popClass"                               
                            },
                            initList:(val)=>{
                              this.initData();                               
                            },
                          }
                        })
                      ]
                    ),
                    
                  ]);
                }
              }
            ]

            if (this.targetdata) {
              this.targetdata.forEach((item)=>{
                //客户进度
                if(item.dbKey == 'status' && item.options && item.options.length>0){
                  this.options.customerProgressList = item.options.map(option=>{
                    return{
                      name:option.optionValue,
                      val:option.optionId+""
                    }
                  })                  
                }
                //意向等级
                if(item.dbKey == "intention_level" && item.options && item.options.length>0){
                  this.options.customerLevelList = item.options.map(option=>{
                    return{
                      name:option.optionValue,
                      val:option.optionId+""
                    }
                  })                  
                }


                //置业目的
                if(item.dbKey == "intention_purpose" && item.options && item.options.length>0){
                  this.options.intentionPurposeList = item.options.map(option=>{
                    return{
                      name:option.optionValue,
                      val:option.optionId+""
                    }
                  })
                }

                //意向业态
                if(item.dbKey == "intention_product" && item.options && item.options.length>0){
                  this.options.intentionProductList = item.options.map(option=>{
                    return{
                      name:option.optionValue,
                      val:option.optionId+""
                    }
                  })
                }
                //意向户型
                if(item.dbKey == "intention_house_type" && item.options && item.options.length>0){
                  this.options.intentionHouseTypeList = item.options.map(option=>{
                    return{
                      name:option.optionValue,
                      val:option.optionId+""
                    }
                  })
                }
              })
            }

            // for (let i = 0; i < this.targetdata.length; i++){
            //   for (let g = 0; g < this.columns2.length; g++){
            //     if(this.targetdata[i].dbKey === this.columns2[g].key) {
            //       this.columns.push(columns[g])
            //     }
            //   }
            // }
            this.targetdata.forEach(item=>{
               if(item.dbKey in this.columns2){
                this.columns.push(this.columns2[item.dbKey])
              } 
            })
            this.columns = [...this.columns, ...temporary]
          })
          .catch((err) => {
            this.$Message.error(err);
          });
      },

      importDownload(id){
        let params = {
          id:id
        }
        buildExport( "客户导入明细", "/dt-business/userImportParameterRecord/exportParameterExcel", params ); 
      },
      handleError(val){
        console.log(val,'失败')
        this.$Message.error(val.msg);
      },


      // 选择案场
      nameCrimeSceneFun(val) {
        console.log(val);
        if (
          this.options.type.split("-")[0] == "Checkbox" ||
          this.options.type.split("-")[3] == "multiple"
        ) {
          this.options[this.options.type.split("-")[1]] = [];
        } else if (this.options.type.split("-")[0] == "AutoComplete") {
          this.selectSearchList = [];
          this.selectSearchVal = "";
          this.options[this.options.type.split("-")[1]] = "";
          this.options[this.options.type.split("-")[2]] = "";
        } else {
          this.options[this.options.type.split("-")[1]] = "";
        }
        this.options.left = -1000;
        this.options.top = -1000;

        this.buildingAlias = val.label;
        this.$tool.setStorage({caseBuildingId: JSON.stringify(val.value)});
        this.$tool.clearStorage(['customerListFormStatistics'])
        this.nameCrimeSceneVal = val.value
        this.options.nameCrimeSceneName = val.label
        this.options.nameCrimeSceneVal = val.value;

        let index =  this.nameCrimeSceneList.findIndex(item=>item.buildingId == val.value)
        this.options.cityCode = this.nameCrimeSceneList[index].cityCode;
        console.log(this.options.cityCode,'this.options.cityCode111');
        this.pageData.page = 1;

        this.getCustomerHeadList()   
        this.initData();
        this.aggChannelQueryGroupList();//渠道数据
        console.log("下选");
        this.reUserByName(); //顾问
        this.getSelectAggregationCriteria();//面积等筛选     
        this.getAreaList();//获取区域列表     
      },
      // table 鼠标移到三角形事件
      thMouseoverFun(event, type, placeholder, width) {
        this.options.type = type
        this.options.placeholder = placeholder
        this.options.left = event.currentTarget.getBoundingClientRect().left - (width/2 - 5) <= 200 ? 200 : (event.currentTarget.getBoundingClientRect().left - (width/2 - 5) + width) > document.documentElement.clientWidth ? (document.documentElement.clientWidth - width) : event.currentTarget.getBoundingClientRect().left - (width/2 - 5)
        this.options.iconLeft = event.currentTarget.getBoundingClientRect().left
        this.options.top = event.currentTarget.getBoundingClientRect().top + 24
        this.options.width = width
      },
      // table 鼠标离开三角形事件
      thMouseoutFun() {
        this.options.setTimeout = setTimeout(() => {
          this.options.left = -1000
          this.options.top = -1000
        },100)
      },
      // table 头部配置
      tableHeadList() {
        this.options.type = 'tableTrue'
      },
      // table from 取消事件
      cancelFilterFun(options) {
        console.log('table取消事件');
        this.$refs.TableHeight.$refs.body.scrollTop=0;
        this.initData()
      },
      // table from 确定事件
      okFilterFun(options) {
        console.log('table确定事件');
        this.$refs.TableHeight.$refs.body.scrollTop=0;
        this.initData()
      },
      openChangeFun(val){
        console.log(val,'接受');
        
        this.reUserByName(val)
      },
      // 分页 页码改变事件
      pageOnChangeFun(page) {
        console.log('页码改变事件');
        this.pageData.page = page;
        this.$refs.TableHeight.$refs.body.scrollTop=0;
        this.initData();       
      },
      // 分页 每页条数改变事件
      pageOnPageSizeChangeFun(rows) {
        console.log('每页条数改变事件s');
        this.pageData.rows = rows;
        this.pageData.page = 1;
        this.$refs.TableHeight.$refs.body.scrollTop=0;
        this.initData();

      },
      //初始化获取数据
      initData() {
        this.loading = true
          console.log(this.options,'this.options');
          //德勤 客户列表
          let params = {
            page: this.pageData.page,
            rows: this.pageData.rows,
            buildingId:this.nameCrimeSceneVal,//楼盘id
            userCustomerId:JSON.parse(this.$tool.getStorage("customerListFormStatistics"))||[],//首页统计面板过来, //用户客户ID

            status:this.options.customerProgressVal||[],//客户进度

            channelSource:this.options.sourceChannelVal||[],//来源渠道
            intentionLevel:this.options.customerLevelVal||[],//意向等级

            intentionPurpose:this.options.intentionPurposeVal||[],//置业目的
            intentionProduct:this.options.intentionProductVal||[],//意向业态
            intentionHouseType:this.options.intentionHouseTypeVal||[],//意向户型

            userIds:this.options.attributionConsultantVal||[],//归属顾问
            
            checkInMethod:this.options.checkInMethodVal||[],//签到方式            
            createMethod:this.options.sourceTypeVal||[],//	创建方式
            intentionRegion:this.options.areaVal||[],//意向区域

            intentionTotalPrice:this.options.intentionTotalPriceVal||[],//意向总价
            intentionArea:this.options.intentionAreaVal||[],//意向面积
            intentionAveragePrice:this.options.intentionAveragePriceVal||[],//意向单价       
            
            // customerName:'',//客户姓名(支持模糊查询)
            // ustomerPhone:'',//客户手机号(最少输入四位,同时搜索主号码和备用号码)
            customerName: this.options.customerName,
            customerPhone: this.options.phoneNumber,
            
            customerCreateStartTime:this.options.createTimeVal && this.options.createTimeVal[0] && Helper.timestampToTime(this.options.createTimeVal[0],'date')+" 00:00:00" || "",//创建开始时间
            customerCreateEndTime:this.options.createTimeVal && this.options.createTimeVal[1] && Helper.timestampToTime(this.options.createTimeVal[1],'date')+" 23:59:59" || "",//创建结束时间
            lastFollowUpStartTime:this.options.lastVisitTimeVal && this.options.lastVisitTimeVal[0] && Helper.timestampToTime(this.options.lastVisitTimeVal[0],'date')+" 00:00:00" || "",//最近跟进开始时间lastVisitTimeVal
            lastFollowUpEndTime:this.options.lastVisitTimeVal && this.options.lastVisitTimeVal[0] && Helper.timestampToTime(this.options.lastVisitTimeVal[1],'date')+" 23:59:59" || "",//最近跟进结束时间
            lastVisitStartTime:this.options.lastFollowUpTimeVal && this.options.lastFollowUpTimeVal[0] && Helper.timestampToTime(this.options.lastFollowUpTimeVal[0],'date')+" 00:00:00" || "",//最近到访开始时间lastFollowUpTimeVal
            lastVisitEndTime:this.options.lastFollowUpTimeVal && this.options.lastFollowUpTimeVal[0] && Helper.timestampToTime(this.options.lastFollowUpTimeVal[1],'date')+" 23:59:59" || "",//最近到访结束时间

            //  sidx:"",//排序字段
            //  sord:'',//排序类型,asc:从小到大,desc:从大到小


          }
          this.exportParams = params

          getCustomerListNew(params).then(res=>{
            console.log("获取客户列表zjzzzzzzzzzzzzzzzzzzz",res)
            this.loading = false
            if (res && res.records) {
              this.data1 = res.records
              this.pageData.total = Number(res.total)
              this.$nextTick(() => {
                this.onresizeHeight = window.innerHeight - this.$refs.TableHeight.$el.offsetTop - 100
                
                // let tabBodyHeight = this.$refs.TableHeight.$children[1].$el.clientHeight
                // let hh = window.innerHeight - this.$refs.TableHeight.$el.offsetTop - 100

                // console.log(this.$refs.TableHeight,'我是表格的数据');
                // console.log(this.$refs.TableHeight.$children[1].$el.clientHeight,'我是表格的数据children');
                // console.log(hh,"屏幕高度减去表格上和分页高度");

                // if(tabBodyHeight<hh){
                //   this.onresizeHeight = tabBodyHeight<65?100:tabBodyHeight+40+10
                // }else{
                //   this.onresizeHeight = hh
                // }

                
              });              
            } else {
              this.pageData.total = 0
              this.data1 = []
            }
            
          }).catch(err=>{
            this.loading = false
            this.$Message.error(err)
          })
      },
      // 新建客户
      newCustomerFun() {
        this.$router.push({path:'/customerManagement_center/allCustomers/newCustomer'});
      },
      // 导出Excel
      exportExcelFun(val) {
        var params={
          queryWebCustomerListDTO:this.exportParams
        };
        params.queryWebCustomerListDTO.rows=9999;
        if(val==1){
          params.type=1
        }else{
          params.type=2        
        }


        console.log(params,this.exportParams,'paramsAll');
        
        
        buildExport("客户列表数据", '/dt-business/web/customer/list/export', params);
      },

      assignCustomers(){
        this.$router.push({
          path:'/customerManagement_center/allCustomers/assignCustomers',
        });      
        
      },


      // 查看详情
      viewClick(rows) {
          if (this.nameCrimeSceneVal) {
            let cityCode = this.nameCrimeSceneList.find(item=>item.buildingId == this.nameCrimeSceneVal).cityCode;
            this.$router.push({path:'/customerManagement_center/allCustomers/details', query:{customerId: rows.customerId, userCustomerId: rows.userCustomerId, buildingId: this.nameCrimeSceneVal,id:rows.customerId,cityCode}});
          }
      },
      
      getAreaList(){
        cityBaseList({level: 4, parentCode: this.options.cityCode}).then(res=>{
          console.log("获取区域列表",res)
          if (res) {
            this.options.areaList = res.list.map(item=>{
              item.name = item.cityName;
              item.val = item.cityId;
              return item;
            })
          }
        }).catch(err=>{
          this.$Message.error(err)
        })
      },
      //归属顾问
      reUserByName(val=' '){
        console.log(val,'aaaaaaaaa');
        let params = {
          buildingId:this.nameCrimeSceneVal,
          userName:val
        }
        getUserByName(params).then(res=>{
          console.log(res,'归属顾问');
          console.log(typeof(res) ,'归属顾问');
          let resData =res;          
          // if(typeof(res)=="string"){
          //     resData = JSON.parse(res);
          // }else{
          //   resData = res;
          // }
         
          if (resData&&resData.length) {
            this.options.attributionConsultantList = resData.map(item=>{
              item.name = item.userName;
              item.val = item.userId;
              return item;
            })
          }else{
            this.options.attributionConsultantList = []
          }
          
          
        }).catch(err=>{
          console.log("走了catch");
          // this.$Message.error(err)
        })
      },


      changeArrayToNum(obj,unit){
        // console.log(obj,);
        let str
        if(obj.start == ''||obj.start == '0'){
              str = obj.end + unit + '以下'
            
          }else if(obj.end == ''||obj.end > 99999){
              str = obj.start + unit + '以上'
  
          }else{
            str = obj.start+'~'+obj.end + unit
          
          }
        return str;
      },


      //意向面积等筛选
      getSelectAggregationCriteria(){
        this.options.intentionAreaList=[];
        this.options.intentionAveragePriceList=[];
        this.options.intentionTotalPriceList=[];
        selectAggregationCriteria({cityCode:this.options.cityCode}).then(res=>{
          console.log("意向面积等筛选",res)
          if(res.areaList&&res.areaList.length){
            res.areaList.map(item=>{
               this.options.intentionAreaList.push(
                 {
                    name :this.changeArrayToNum(JSON.parse(item.paramValues),'㎡'),
                    val :item.searchParamId
                 }
               )
            })
          }
          if(res.priceList&&res.priceList.length){
            res.priceList.map(item=>{
               this.options.intentionAveragePriceList.push(
                 {
                    name :this.changeArrayToNum(JSON.parse(item.paramValues),'元'),
                    val :item.searchParamId
                 }
               )
            })
          }
          if(res.totalList&&res.totalList.length){
            res.totalList.map(item=>{
               this.options.intentionTotalPriceList.push(
                 {
                    name :this.changeArrayToNum(JSON.parse(item.paramValues),'万元'),
                    val :item.searchParamId
                 }
               )
            })
          }

          
          console.log(this.options.intentionAveragePriceList,'this.options.intentionAveragePriceList');
        }).catch(err=>{
          this.$Message.error(err)
        })
      },

      
      //获取渠道列表
      aggChannelQueryGroupList() {
        aggChannelQueryGroupBuilding({cityCode: this.options.cityCode,page:1,rows:100,buildingId:this.options.nameCrimeSceneVal}).then(res=>{
          console.log(res,"来源渠道列表",JSON.parse(JSON.stringify(res)) );
          if (res&&res.list&&res.list.length > 0) {
            this.sourceChannelList = res.list
            console.log('我是来源渠道啊',this.sourceChannelList);
          } else {
            this.sourceChannelList = []
          }
        }).catch(err=>{
          console.log("渠道配置列表报错", err)
        })
      },
      getInit(){
        console.log('第一次进来');
        //加载页面数据
        this.appId = this.$tool.getStorage("appId");
        this.pageData= {
            total: 0,
            page: 1,
            rows: 50,
            pageSizeOpts: [50, 40, 30, 20, 10]
          }
        this.columns = []
        // 查询人员案场
        teams({}).then(res=>{
          console.log("查询案场",res)
          if (res && res.list && res.list.length>0) {
            // if(!this.statisticsFlag){
            //   this.$tool.clearStorage(['customerListFormStatistics'])
            // }
            this.nameCrimeSceneList = res.list

            if(this.caseBuildingId){
              this.nameCrimeSceneVal=this.caseBuildingId;
              let index =  res.list.findIndex(item=>item.buildingId == this.caseBuildingId)
              this.options.cityCode =  res.list[index].cityCode;
              this.options.nameCrimeSceneVal = this.caseBuildingId;
              this.options.nameCrimeSceneName = res.list[index].buildingAlias;
              this.buildingAlias = res.list[index].buildingAlias;
            }else{
              this.nameCrimeSceneVal=res.list[0].buildingId;
              this.options.nameCrimeSceneName = res.list[0].buildingAlias
              this.options.nameCrimeSceneVal = res.list[0].buildingId;
              this.options.cityCode = res.list[0].cityCode;
              this.buildingAlias = res.list[0].buildingAlias
            }


            


            // res.list.forEach(item=>{
            //   if (item.buildingId == this.nameCrimeSceneVal) {
            //     this.buildingAlias = item.buildingAlias
            //   }
            // })
            
            // this.options.nameCrimeSceneName = res.list[0].buildingAlias
            // this.options.nameCrimeSceneVal = res.list[0].buildingId;
            // this.options.cityCode = res.list[0].cityCode;



      
            this.getCustomerHeadList()   
            this.initData();
            this.aggChannelQueryGroupList();//渠道数据
            this.reUserByName(); //顾问
            this.getSelectAggregationCriteria();//面积等筛选     
            this.getAreaList();//获取区域列表       



          } else {
            this.nameCrimeSceneList = []
            this.nameCrimeSceneVal = ''
            this.options.nameCrimeSceneName = ''
          }
           
        }).catch(err=>{
          this.$Message.error(err)
        })
      }
    },
    computed: {

    },
    created() {
      console.log(this.columns2,"columns2");
    },

    beforeRouteEnter (to, from, next) {  
      if(from.name == 'allCustomersDetails'){
        to.meta.isBack=true;
      }else{
      }
      next(vm =>{
        if(from.name == 'statistics'){
          vm.statisticsFlag = true;
        }
      })
    },

    activated () {
      this.caseBuildingId=JSON.parse(this.$tool.getStorage("caseBuildingId"));
      // appId   36=>德勤   49=>B+
      this.$refs.TableHeight.$refs.body.scrollTop = JSON.parse(this.$tool.getStorage("scrollTopValNum"));
       // 如果不是从详情页面返回，则重新加载数据
      if (!this.$route.meta.isBack) {
        this.getInit();
      }else{
        if(this.nameCrimeSceneVal != this.caseBuildingId) {
          this.getInit();
        }
      }
      // 从新设置页面得路由元信息
      this.$route.meta.isBack = false
    },

    beforeRouteLeave (to, from, next) { 
      this.$tool.clearStorage(['customerListFormStatistics'])
      if(to.name == 'allCustomersDetails'){
        this.$tool.setStorage({ scrollTopValNum: JSON.stringify( this.$refs.TableHeight.$refs.body.scrollTop)});
      }else{
        this.$tool.clearStorage(['scrollTopValNum'])
      }
      next()
    },
    
    mounted() {
      window.onresize = () => {
        return (() => {
          setTimeout(() => {
            this.onresizeHeight = window.innerHeight - this.$refs.TableHeight.$el.offsetTop - 100
            // let tabBodyHeight = this.$refs.TableHeight.$children[1].$el.clientHeight
            // let hh = window.innerHeight - this.$refs.TableHeight.$el.offsetTop - 100

            // console.log(this.$refs.TableHeight,'我是表格的数据');
            // console.log(this.$refs.TableHeight.$children[1].$el.clientHeight,'我是表格的数据children');
            // console.log(hh,"屏幕高度减去表格上和分页高度");


            // if(tabBodyHeight<hh){
            //   this.onresizeHeight = tabBodyHeight<65?100:tabBodyHeight+40+10
            // }else{
            //   this.onresizeHeight = hh
            // }
          }, 10);
        })();
      };
    },
    beforeDestroy(){
      // this.$tool.clearStorage(['customerListFormStatistics'])
    }
  }
</script>
<style lang="scss" scoped>
.popClass{
  display: none!important;
}

 .allCustomersManagement{
    .newArticleStyle{
      padding: 10px 14px;
      overflow: hidden;
      .imprt{
        float:right;
        display: flex;
        flex-direction: row;
        >*{
          margin-right:5px;
        }
        .impotBtn{
          line-height: 2;
          cursor: pointer;
          color:#2d8cf0;
          text-align: center;
          &:first-child{
            border-bottom:1px #e8eaec solid;
          }
        }
      }
    }
  }
  /* page */
  .pagePublicStyle {
    width: 100%;
    margin: 14px 0;
    height: 32px;
    padding: 14px 10px;
    .totalCount {
      position: absolute;
      height: 32px;
      line-height: 32px;
      display: inline-block;
      vertical-align: top;
      color: #657180;
    }
    .pager {
      display: inline-block;
      vertical-align: top;
      position: absolute;
      right: 20px;
      background-color: #fff;
      padding-left: 50px;
    }
  }
  .transferFooter {
    margin-top: 20px;
    display: flex;
    flex-direction: row;
    justify-content: center;
    button {
      width: 80px;
      margin: 0 10px;
    }
  }
</style>

<style>






.N_poptip .ivu-poptip-inner{
  background: rgba(235, 247, 255, 1)!important;
  white-space: normal;      
}
.featureZ{
    text-overflow: -o-ellipsis-lastline;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    height: 40px;
}
/* .M_poptip{
  padding-bottom:50px!important;
} */
</style>
